#--------------------------------------------------------------------
#   shadow test
#   (C) 2001 RadonLabs GmbH
#--------------------------------------------------------------------
set ('/sys/servers/shadow.setcastshadows',1)
sel ('/usr/scene')
# an ambient light node
amb=new ('nlightnode','amb')
sel ('amb')
amb.setcolor(0,0,0,0)
sel ('..')
# a rotating directional lightnode
light=new ('n3dnode','light')
sel ('light')
light.rx(-45)
l=new ('nlightnode','l')
sel ('l')
l.settype('directional')
l.setcolor(1,1,1,1)
l.setcastshadows(1)
sel ('..')
ip=new ('nipol','ip')
sel ('ip')
ip.connect('ry')
ip.addkey1f(0,0)
ip.addkey1f(20,360)
sel ('..')
sel ('..')
# some ground geometry
land=new ('n3dnode','land')
sel ('land')
land.sxyz(2,1,2)
mesh=new ('nmeshnode','mesh')
sel ('mesh')
mesh.setfilename('../meshes/testplane.n3d')
sel ('..')
tex=new ('ntexarraynode','tex')
sel ('tex')
tex.settexture(0,'../bmp/marble.bmp','none')
tex.setgenmipmaps(0,1)
sel ('..')
shd=new ('nshadernode','shd')
sel ('shd')
shd.setnumstages(1)
shd.setcolorop(0,"mul tex prev" )
shd.begintunit(0)
shd.setminmagfilter("linear_mipmap_nearest","linear")
shd.settexcoordsrc("uv0")
shd.endtunit()
shd.setdiffuse(1.000000,1.000000,1.000000,1.000000)
shd.setemissive(0.000000,0.000000,0.000000,0.000000)
shd.setambient(1.000000,1.000000,1.000000,1.000000)
shd.setlightenable(1)
shd.setalphaenable(0)
shd.setzwriteenable(1)
sel ('..')
sel ('..')
# a donut routine
def donut(name,tx,ty,tz,time):
	name1=new ('n3dnode',name)
	sel (name)
	name1.txyz(tx,ty,tz)
	rot=new ('nipol','rot')
	sel ('rot')
	rot.connect('rxyz')
	rot.addkey3f(0,0,0,0)
	rot.addkey3f(time,360,720,1440)
	sel ('..')
	mesh=new ('nmeshnode','mesh')
	sel ('mesh')
	mesh.setfilename("../meshes/sdonut.n3d")
	mesh.setcastshadow(1)
	sel ('..')
	tex=new ('ntexarraynode','tex')
	sel ('tex')
	tex.settexture(0,'../bmp/marble.bmp','none')
	tex.setgenmipmaps(0,1)
	sel ('..')
	shd=new ('nshadernode','shd')
	sel ('shd')
	shd.setnumstages(1)
	shd.setcolorop(0,"mul tex prev" )
	shd.begintunit(0)
	shd.setminmagfilter("linear_mipmap_nearest","linear")
	shd.settexcoordsrc("uv0")
	shd.endtunit()
	shd.setdiffuse(1.000000,1.000000,1.000000,1.000000)
	shd.setemissive(0.000000,0.000000,0.000000,0.000000)
	shd.setambient(1.000000,1.000000,1.000000,1.000000)
	shd.setlightenable(1)
	shd.setalphaenable(0)
	shd.setzwriteenable(1)
	sel ('..')
	sel ('..')
# generate a bunch of shadow casting donuts
for y in range (3):
	for x in range(3):
		for z in range(3):
			n='d_'+str(x)+str(y)+str(z)
			donut(n,x*10,y*10+5,z*10,(x+1)*5)	
#donut ('d_($x)_($y)_($z)',posx,posy,posz,'[expr','($x','+',y,'+',z,'+','1)','*','5]')
